﻿using Persistencia;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dlls
{
   public class ProducaoDLL
    {
          Context context;

          public ProducaoDLL()
        {
            context = new Context();
        }

  
        public IEnumerable<Producao> List() {
            return (from o in context.Producao select o).ToList();
        }

        public void Insert(Producao producao) 
        {
            context.Producao.InsertOnSubmit(producao);
            context.SubmitChanges();
        }

        public void Update(int codigo, Producao producao)
        {
            Producao prod = context.Producao.SingleOrDefault(o => o.Codigo == codigo);
            context.SubmitChanges();
        }

        public void Delete(int codigo,Producao producao) 
        {
            context.Producao.DeleteOnSubmit(producao);
            context.SubmitChanges();
        }

    }
}
